/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-11-13     ganze       the first version
 */
#ifndef APPLICATIONS_ST_LSM6DSL_APP_LSM6DSL_H_
#define APPLICATIONS_ST_LSM6DSL_LSM6DSL_H_

#include "libraries/lsm6dsl.h"
#include "libraries/lsm6dsl_reg.h"

#include <sensor.h>

#ifndef LSM6DSL_ADDR_DEFAULT
#define LSM6DSL_ADDR_DEFAULT 0x68 /* SA0 connect to GND, 0x69 if connect to VDDIO */
#endif

#define LSM6DSL_SPI_BUSNAME "spi1"
#define LSM6DSL_SPI_DEVNAME "spi12"

#define LSM6DSL_ACC_RANGE_2G 2000
#define LSM6DSL_ACC_RANGE_4G 4000
#define LSM6DSL_ACC_RANGE_8G 8000
#define LSM6DSL_ACC_RANGE_16G 16000

#define LSM6DSL_GYR_RANGE_125 125000
#define LSM6DSL_GYR_RANGE_250 250000
#define LSM6DSL_GYR_RANGE_500 500000
#define LSM6DSL_GYR_RANGE_1000 1000000
#define LSM6DSL_GYR_RANGE_2000 2000000

/// @brief SPI接口启动函数
/// @param name
/// @param cfg
/// @return
int rt_spi_lsm6dsl_init(const char *name, struct rt_sensor_config *cfg);

/// @brief
/// @param
/// @return
int rt_lsm6dsl_sensor_register(void);

/// @brief
/// @param p_acce_dev
/// @return
int lsm6dsl_acce_start(rt_device_t *p_acce_dev);

/// @brief
/// @param p_gyro_dev
/// @return
int lsm6dsl_gyro_start(rt_device_t *p_gyro_dev);

#endif /* APPLICATIONS_ST_LSM6DSL_APP_LSM6DSL_H_ */
